/*
 * Organizacion de computadoras (66.20) - TP1 1er Cuatrimestre 2013.
 * 
 * Archivo: ShellSort.c
 * 
 * Integrantes:
 * 
 *      Maximiliano Monzon (82341)
 *      Nahuel Lucero (90365)
 *      Juan Ignacio Lopez Pecora (84700)
 */

#include "ShellSort.h"

void shellsort (char **words, int arraysize){
    
    int i = 0
      , j = 0
      , increment = arraysize / 2;
    char* temp;

    while (increment > 0)
    {
        for (i=0; i < arraysize; i++)
        {
            j = i;
            temp = words[i];
              
            while ((j >= increment) && (strcasecmpmine (words[j-increment],temp) > 0))
            {
                words[j] = words[j - increment];
                j = j - increment;
            }
            words[j] = temp;
        }
        
        if (increment == 2)
            increment = 1;
        else 
            increment = increment * 5 / 11;
    }
}
